class Profile
  include Mongoid::Document

  field :name, type: String
  field :bio, type: String
  field :location, type: String
  field :website, type: String

  has_one :user

  validates_presence_of :name
  validates_length_of :bio, maximum: 160
  validates_format_of :website, :with => /^((http|ftp|https?):\/\/((?:[-a-z0-9]+\.)+[a-z]{2,}))/, :on => :create, :if => :website_filled?

  def website_filled?
    !website.blank?
  end
end